$(function () {
    $.ajax({
        url:"/orderVerify/queryOrderById",
        type:"post",
        dataType:"json",
        success:function (r) {
            console.log(r);
            if (r!=null){
                $("#orderinfo>li").eq(0).children("cite").html(r[0].orderid);
                $("#orderinfo>li").eq(1).children("cite").html(r[0].customname);
                $("#orderinfo>li").eq(2).children("cite").html(r[0].phone);
                $("#orderinfo>li").eq(3).children("cite").html(r[0].ordertime);
                $("#orderinfo>li").eq(4).children("cite").html(r[0].totalprice);
                $("#orderinfo>li").eq(5).children("cite").html(r[0].operatorname);
            }
           else{
                $("#orderinfo>li").html("");
            }
        }
    })

    $.ajax({
        url:"/orderVerify/queryOrderDetailByOrderID",
        type:"post",
        datatype: "json",
        success:function (r) {
            console.log(r)
            var t = "";
            var i = 1;
            for (let j = 0; j < r.length; j++) {
                t += "<tr>\n" +
                    "          <td>"+(i++)+"</td>\n" +
                    "          <td >"+r[j].brandname+"</td>\n" +
                    "          <td>"+r[j].type+"</td>\n" +
                    "          <td>"+r[j].model+"</td>\n" +
                    "          <td>"+r[j].num+"</td>\n" +
                    "          <td>"+r[j].unit+"</td>\n" +
                    "          <td>"+r[j].price+"</td>\n" +
                    "          <td>"+r[j].totalprice+"</td>\n" +
                    "        </tr>";
            }
            $("#orderdetail").html(t);
        }
    })

})

function checksubmit(a) {
    let opinion = $(a).parents().siblings("li").eq(0).children("textarea").val();
    let status = $(a).parents().siblings("li").eq(1).children("select").val();

    if (status==="请选择"){
        alert("请选择结果");
    }else {
        $.ajax({
            url:"/orderVerify/updateOpinion",
            type:"post",
            data:{"opinion":opinion,"status":status},
            datatype: "json",
            success:function (r) {
                if (r==="1"){
                    alert("审核成功，即将返回");
                    location.href="orderExamineList.html";
                }else {
                    alert("审核失败");
                    location.reload();
                }
            }
        })
    }
}